unit Interface_SelectDrive;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TWndSelectDisk = class(TForm)
    ListDrives: TListBox;
    procedure FormShow(Sender: TObject);
    procedure ListDrivesDblClick(Sender: TObject);
    procedure ListDrivesKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private

  public
    LeftPan : Boolean;
    { Public declarations }
  end;

var
  WndSelectDisk: TWndSelectDisk;

implementation

uses Interface_MainWnd;

{$R *.dfm}

procedure TWndSelectDisk.FormShow(Sender: TObject);
var
  i, j: integer;
  buf: array [0..499] of char;
  DrvStr: array [0..9] of char;
  LogDrives: set of 0..25;
begin
  ListDrives.Clear;
  integer(LogDrives) := GetLogicalDrives;

  GetLogicalDriveStrings(1000, buf);
  i := 0;
  repeat
    FillChar(DrvStr, SizeOf(DrvStr), #0);
    j := 0;
    repeat
      DrvStr[j] := buf[i];
      inc(j);
      inc(i);
    until
      (buf[i] = #0) or (j > 9);
    inc(i);
    ListDrives.Items.Add(DrvStr);
  until
    ((buf[i-1] = #0) and (buf[i] = #0)) or (i > 499);

end;

procedure TWndSelectDisk.ListDrivesDblClick(Sender: TObject);
begin
  WndMain.BrowseList(ListDrives.Items[ListDrives.ItemIndex], '*.*', LeftPan);
  Close;
end;

procedure TWndSelectDisk.ListDrivesKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_RETURN then
    ListDrivesDblClick(Sender);
end;

end.
